//package com.zh.config;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.listener.ChannelTopic;
//import org.springframework.data.redis.listener.RedisMessageListenerContainer;
///**
// * @Description:
// * @ClassName RedisMessageListener
// * @date: 2021.04.21 10:35
// * @Author: zhanghang
// */
//
//@Configuration
//public class RedisMessageListener {
//    @Autowired
//    private RedisConnectionFactory redisConnectionFactory;
//
//    @Autowired
//    private RedisTemplate<Object, Object> redisTemplate;
//
//
//    @Bean
//    public RedisMessageListenerContainer redisMessageListenerContainer() {
//        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
//        container.setConnectionFactory(redisConnectionFactory);
//        // 解决bean注入失败问题
//        RedisExpireListener redisExpireListener = new RedisExpireListener();
//        redisExpireListener.setRedisTemplate(redisTemplate);
//        // 监听缓存key过期
//        container.addMessageListener(redisExpireListener, new ChannelTopic("__keyevent@0__:expired"));
//        return container;
//    }
//}
//
